<div id="index_page">	
<?php
// xu ly phan trang
$total_book = db_select_all_data("orders");
$total_post = count($total_book);
$number_post_page = 40;
if(isset($_POST['set_number_post']))
{	
	$number_post_page = $_POST['set_number_post'];
	$_SESSION['set_number_post'] = $number_post_page;
}
else 
{
	if($_SESSION['set_number_post'] != null)
		$number_post_page = $_SESSION['set_number_post'];
}
	
if(!isset($_GET['p']))
{
	$start = 0;
	$end = $number_post_page;
}
else 
{
	$cp = $_GET['p'];
	$end = $number_post_page*$cp;
	$start = $end - $number_post_page;
}

$number_page = ceil($total_post/$number_post_page);
if($number_page>1)
{
	for($i=1;$i<=$number_page;$i++)
	{
		if($cp==$i)
		{
		?>
		<a href="<?php bloginfo('home');?>/wp-admin/admin.php?page=tour-setting&action=tour-booked&p=<?php echo $i;?>" style="color: red; font-weight: bold;"><?php echo $i;?></a> &nbsp;|&nbsp;
		<?php 	
		}
		else 
		{
		?>
		<a href="<?php bloginfo('home');?>/wp-admin/admin.php?page=tour-setting&action=tour-booked&p=<?php echo $i;?>"><?php echo $i;?></a> &nbsp;|&nbsp;
		<?php 	
		}
	}
}
?>
&nbsp;&nbsp;
&nbsp;&nbsp;
<form action="" method="post">
<select name="set_number_post" onchange="this.form.submit();">
	<option value="">-Set Number Post-</option>
	<option <?php if($_SESSION['set_number_post']==30) echo 'selected="selected"';?> value="30">30</option>
	<option <?php if($_SESSION['set_number_post']==40) echo 'selected="selected"';?> value="40">40</option>
	<option <?php if($_SESSION['set_number_post']==50) echo 'selected="selected"';?> value="50">50</option>
	<option <?php if($_SESSION['set_number_post']==60) echo 'selected="selected"';?> value="60">60</option>
	<option <?php if($_SESSION['set_number_post']==80) echo 'selected="selected"';?> value="80">80</option>
	<option <?php if($_SESSION['set_number_post']==100) echo 'selected="selected"';?> value="100">100</option>
	<option <?php if($_SESSION['set_number_post']==150) echo 'selected="selected"';?> value="150">150</option>	
</select>
</form>

		
				<table>
						
						<tr class="first-header">
							<td> Customer </td>
							<td> Customer Email </td>
							<td> Customer Tel </td>
							<td> Payment Status </td>
							<td> Date </td>
							<td> Actions </td>				
						</tr> 
						<?php
						$visa_list = db_select_all_data_visa_limit("visas",$start,$number_post_page); //db_select_all_data_order("visas");
						
						$home_url = get_bloginfo('home');
						if($visa_list)
						{ 
							foreach ($visa_list as $value) 
							{
								$customers = db_select_data_by_int("customers", "ID", $value->customerID);								
								$paymentID = db_select_data_by_int("payments", "ID", $value->paymentID);
								//print_r($paymentID);
							?>
							<tr class="item-second">
								<td> <?php echo $customers[0]->customerName;?></td>
								<td> <?php echo $customers[0]->customerEmail;?></td>
								<td> <?php echo $customers[0]->customerPhone;?></td>
								<td> <?php echo $paymentID[0]->paymentStatus;?></td>
								<td> <?php echo $value->date;?></td>
								<td>							
									<a href="<?php echo $home_url;?>/wp-admin/admin.php?page=travel-visa-setting&visa=<?php echo $value->ID;?>&cus=<?php echo $customers[0]->ID;?>">View</a> &nbsp;|&nbsp;
									<a href="<?php echo $home_url;?>/wp-admin/admin.php?page=travel-visa-setting&del=<?php echo $value->ID;?>&cus=<?php echo $customers[0]->ID;?>">Delete</a>
								</td>								
							</tr>
							<?php 
							}						
						} 
						?>
					</table>	
				</div>  